<template>
  <el-dialog 
    v-model="internalVisible" 
    title="文件上传" 
    width="45%" 
    center
    @close="handleDialogClose"
  >
    <div class="upload-container">
      <h2>上传文件到文件夹 {{ props.folderId }}</h2>
      
      <el-select 
        v-model="selectedVersion" 
        placeholder="请选择密钥" 
        :loading="isLoading"
        class="version-selector"
      >
        <el-option
          v-for="item in versions"
          :key="item.versionId"
          :label="`${item.displayName} (${item.formattedDate})`"
          :value="item.versionId"
        />
        <template v-if="versions.length === 0 && !isLoading">
          <el-option disabled value="">暂无密钥数据</el-option>
        </template>
      </el-select>
      
      <!-- 加密选项区域 -->
      <div class="encryption-section">
        <h3>加密选项 <el-icon class="info-icon" @click="showEncryptionInfo = true"><InfoFilled /></el-icon></h3>
        
        <!-- 加密模式选择 -->
        <div class="encryption-mode-select">
          <el-radio-group v-model="encryptionMode" size="large">
            <el-radio-button label="auto">系统默认</el-radio-button>
            <el-radio-button label="custom">自主选择</el-radio-button>
          </el-radio-group>
          
          <div class="mode-description">
            <p v-if="encryptionMode === 'auto'">
              系统将根据文件自动选择加密方式：
              <el-tag type="success" size="small">标准加密</el-tag>
              <el-tag type="warning" size="small">增强加密</el-tag>
            </p>
            <p v-else>请根据文件安全需求手动选择加密方式</p>
          </div>
        </div>
        
        <!-- 加密选项卡片 -->
        <div class="encryption-cards" v-if="encryptionMode === 'custom'">
          <div 
            class="encryption-card" 
            :class="{ 'selected': encryptionType === 'standard' }"
            @click="encryptionType = 'standard'"
          >
            <div class="card-icon">
              <el-icon><Lock /></el-icon>
            </div>
            <div class="card-content">
              <h4>标准加密</h4>
              <p>适用于短期存储或需要频繁访问的文件</p>
              <ul>
                <li>快速加密/解密</li>
                <li>适用于日常文件</li>
                <li>安全性适中</li>
              </ul>
            </div>
            <div class="card-footer">
              <el-tag type="success" effect="dark">推荐</el-tag>
            </div>
          </div>
          
          <div 
            class="encryption-card" 
            :class="{ 'selected': encryptionType === 'enhanced' }"
            @click="encryptionType = 'enhanced'"
          >
            <div class="card-icon enhanced">
              <el-icon><Lock /></el-icon>
            </div>
            <div class="card-content">
              <h4>增强加密</h4>
              <p>适用于长期存储的敏感文件或机密文档</p>
              <ul>
                <li>军事级加密算法</li>
                <li>极高的安全性</li>
                <li>文件访问速度较慢</li>
              </ul>
            </div>
            <div class="card-footer">
              <el-tag type="warning" effect="dark">高级</el-tag>
            </div>
          </div>
        </div>
        
        <div class="encryption-warning" v-if="encryptionMode === 'custom' && encryptionType === 'enhanced'">
          <el-alert 
            title="增强加密提示" 
            type="warning" 
            :closable="false"
            show-icon
          >
            <p>增强加密使用复杂的多层加密算法，提供最高级别的安全性，但会显著增加文件访问时间。</p>
            <p>建议仅对需要长期存储且访问频率较低的敏感文件使用此选项。</p>
          </el-alert>
        </div>
      </div>
      
      <el-upload
        class="upload-box"
        :auto-upload="false"
        :on-change="handleFileChange"
        :show-file-list="false"
      >
        <el-button type="primary">选择文件</el-button>
        <template #tip>
          <div class="selected-file" v-if="selectedFile">
            已选择文件：{{ selectedFile.name }} ({{ formatFileSize(selectedFile.size) }})
          </div>
        </template>
      </el-upload>
      
      <el-button 
        @click="confirmUpload" 
        type="success" 
        :loading="isProcessing"
        class="confirm-btn"
        :disabled="!selectedFile || !selectedVersion"
      >
        {{ confirmButtonText }}
      </el-button>
      
      <div class="progress-list">
        <!-- 上传进度列表 -->
        <div class="upload-item" v-for="upload in uploadFiles" :key="upload.id">
          <div class="file-info">
            <span class="file-name">{{ upload.fileName }}</span>
            <span class="file-size">{{ formatFileSize(upload.size) }}</span>
          </div>
          <div class="progress-info">
            <el-progress 
              :percentage="upload.uploadPercentage" 
              :status="getProgressStatus(upload)"
              :stroke-width="16"
              striped
              :striped-flow="upload.status === 'uploading'"
            />
            <div class="progress-details">
              <span class="speed">{{ upload.uploadSpeed }}</span>
              <span class="status">{{ getStatusText(upload.status) }}</span>
            </div>
          </div>
          <div class="actions">
            <el-button 
              v-if="upload.status === 'uploading'" 
              @click="pauseUpload(upload.id)"
              size="small"
              icon="el-icon-video-pause"
            />
            <el-button 
              v-if="upload.status === 'paused'" 
              @click="resumeUpload(upload.id)"
              size="small"
              icon="el-icon-video-play"
            />
            <el-button 
              @click="removeUpload(upload.id)"
              size="small"
              icon="el-icon-close"
            />
          </div>
        </div>
      </div>
    </div>
  </el-dialog>

  <!-- 加密信息对话框 -->
  <el-dialog
    v-model="showEncryptionInfo"
    title="加密类型说明"
    width="500px"
  >
    <div class="encryption-info">
      <h3><el-icon><Lock /></el-icon> 加密类型说明</h3>
      
      <div class="info-section">
        <h4>系统默认加密策略</h4>
        <p>系统会根据文件大小自动选择最合适的加密方式：</p>
        <ul>
          <li>使用<span class="highlight">标准加密</span>，保障日常使用效率</li>
          <li>使用<span class="highlight">增强加密</span>，提供更高级别的安全保护</li>
        </ul>
        <p>这种智能选择方式平衡了安全性和性能，适合大多数使用场景。</p>
      </div>
      
      <div class="info-section">
        <h4>标准加密</h4>
        <p>使用混沌加密算法，提供行业标准的安全保护。适用于日常文件、短期存储或需要频繁访问的文件。</p>
        <p><strong>特点：</strong>加密/解密速度快，安全性高，资源消耗低</p>
      </div>
      
      <div class="info-section">
        <h4>增强加密</h4>
        <p>使用混沌优化进化加密算法，提供军事级别的安全保护。</p>
        <p><strong>特点：</strong></p>
        <ul>
          <li>极高的安全性，可抵御大部分攻击</li>
          <li>适用于敏感文档、长期存储的重要文件</li>
          <li>加密/解密时间显著增加</li>
          <li>文件访问速度降低30%-50%</li>
        </ul>
        <p class="warning">注意：增强加密适用于不需要频繁访问的文件。对于日常使用文件，建议使用标准加密。</p>
      </div>
    </div>
    
    <template #footer>
      <el-button type="primary" @click="showEncryptionInfo = false">我明白了</el-button>
    </template>
  </el-dialog>
</template>

<script setup>
import { ref, computed, onMounted, defineProps, defineEmits, watch, onBeforeUnmount } from 'vue'
import { ElMessage } from 'element-plus'
import axios from 'axios'
import SparkMD5 from 'spark-md5'
import eventBus from '@/utils/eventBus'
import { Lock, InfoFilled } from '@element-plus/icons-vue'
import { useUploadStore } from '@/stores/uploadStore'

const props = defineProps({
  folderId: {
    type: Number,
    required: true
  },
  modelValue: {
    type: Boolean,
    required: true
  }
})

const emit = defineEmits(['update:modelValue', 'upload-success', 'close'])

// 使用内部变量控制弹窗显示
const internalVisible = ref(props.modelValue)

// 监听父组件传入的modelValue变化
watch(() => props.modelValue, (newVal) => {
  internalVisible.value = newVal
})

// 监听内部visible变化并通知父组件
watch(internalVisible, (newVal) => {
  emit('update:modelValue', newVal)
})

// 使用 uploadStore
const uploadStore = useUploadStore()
const uploadFiles = computed(() => uploadStore.activeUploads)

// 响应式数据
const selectedVersion = ref('')
const selectedFile = ref(null)
const versions = ref([])
const isLoading = ref(false)
const isProcessing = ref(false)
const encryptionType = ref('standard')
const encryptionMode = ref('auto') // 加密模式：auto（系统默认）或 custom（自主选择）
const showEncryptionInfo = ref(false)

const confirmButtonText = computed(() => {
  if (isProcessing.value) return '处理中...'
  if (!selectedFile.value) return '请选择文件'
  if (!selectedVersion.value) return '请选择密钥'
  
  if (encryptionMode.value === 'auto') {
    const fileSizeMB = selectedFile.value?.size / (1024 * 1024) || 0
    const autoType = fileSizeMB < 50 ? '标准加密' : '增强加密'
    return `确认上传（系统默认：${autoType}）`
  }
  
  return encryptionType.value === 'enhanced' 
    ? '确认上传（增强加密）' 
    : '确认上传（标准加密）'
})

const formatFileSize = (size) => {
  if (!size) return '0 B'
  const units = ["B", "KB", "MB", "GB"]
  let unitIndex = 0
  while (size >= 1024 && unitIndex < units.length - 1) {
    size /= 1024
    unitIndex++
  }
  return `${size.toFixed(2)} ${units[unitIndex]}`
}

const getProgressStatus = (upload) => {
  if (upload.status === 'error') return 'exception'
  if (upload.status === 'completed') return 'success'
  return 'primary'
}

const getStatusText = (status) => {
  const statusMap = {
    queued: '排队中',
    uploading: '解析中',
    paused: '已暂停',
    completed: '解析完成',
    error: '上传失败'
  }
  return statusMap[status] || status
}

onMounted(() => {
  loadVersions()
  eventBus.on('pause-upload', handlePauseRequest)
  eventBus.on('resume-upload', handleResumeRequest)
})

onBeforeUnmount(() => {
  eventBus.off('pause-upload', handlePauseRequest)
  eventBus.off('resume-upload', handleResumeRequest)
})

async function loadVersions() {
  try {
    isLoading.value = true
    const response = await axios.get('http://localhost:8083/versions')
    
    versions.value = response.data
      .sort((a, b) => new Date(b.createTime) - new Date(a.createTime))
      .map(v => ({
        ...v,
        displayName: v.versionNo.replace(/-/g, '').substring(0, 8),
        formattedDate: new Date(v.createTime).toLocaleDateString('zh-CN')
      }))
    
    if (versions.value.length === 0) {
      ElMessage.warning('没有可用的密钥')
    }
  } catch (error) {
    console.error('获取密钥错误:', error)
    ElMessage.error('获取密钥失败')
  } finally {
    isLoading.value = false
  }
}

function handleFileChange(file) {
  selectedFile.value = file.raw
}

function handleDialogClose() {
  selectedVersion.value = ''
  selectedFile.value = null
  encryptionType.value = 'standard'
  encryptionMode.value = 'auto'
  emit('close')
}

async function confirmUpload() {
  if (!selectedFile.value || !selectedVersion.value) {
    ElMessage.error('请选择文件密钥')
    return
  }
  
  isProcessing.value = true
  const fileSize = selectedFile.value.size
  const fileSizeMB = fileSize / (1024 * 1024)
  
  const MAX_FILE_SIZE = 20 * 1024 * 1024 * 1024;
  if (fileSize > MAX_FILE_SIZE) {
    ElMessage.error("文件大小超过20GB限制")
    isProcessing.value = false
    return
  }
  
  try {
    // 确定加密类型
    let finalEncryptionType = encryptionType.value
    
    if (encryptionMode.value === 'auto') {
      // 系统默认模式：根据文件大小自动选择
      finalEncryptionType = fileSizeMB < 50 ? 'standard' : 'enhanced'
    }
    
    // 创建上传任务对象
    const uploadTask = {
      id: Date.now() + Math.random().toString(36).substring(2),
      fileName: selectedFile.value.name,
      size: fileSize,
      file: selectedFile.value,
      folderId: props.folderId,
      versionId: selectedVersion.value,
      isChunked: fileSizeMB >= 5,
      encryptionType: finalEncryptionType,
      status: 'uploading'
    }
    
    // 使用 store 添加上传任务
    const storeUploadTask = uploadStore.addUpload(uploadTask)
    storeUploadTask.file = selectedFile.value
    
    // 小于50MB使用普通上传
    if (fileSizeMB < 50) {
      await normalUpload(storeUploadTask)
      return
    }
    
    // 计算MD5
    storeUploadTask.md5 = await computeMd5(selectedFile.value, storeUploadTask)
    
    // 检查文件
    await checkFile(storeUploadTask)
    
    // 开始上传
    if (storeUploadTask.needUpload) {
      startChunkUpload(storeUploadTask)
    } else if (storeUploadTask.md5) {
      // 秒传成功处理
      uploadStore.completeUpload(storeUploadTask.id)
      ElMessage.success('文件秒传成功')
      emit('upload-success')
    }
  } catch (error) {
    handleUploadError(error)
  } finally {
    selectedFile.value = null
    isProcessing.value = false
  }
}

function computeMd5(file, uploadTask) {
  return new Promise((resolve) => {
    const chunkSize = 1 * 1024 * 1024
    const fileReader = new FileReader()
    const md5 = new SparkMD5.ArrayBuffer()
    let index = 0
    
    const loadNextChunk = () => {
      if (index >= file.size) {
        resolve(md5.end())
        return
      }
      
      const slice = file.slice(index, index + chunkSize)
      fileReader.readAsArrayBuffer(slice)
    }
    
    fileReader.onload = (e) => {
      md5.append(e.target.result)
      index += chunkSize
      
      // 更新解析进度
      const progress = Math.min(100, Math.round((index / file.size) * 100))
      uploadStore.updateProgress(uploadTask.id, progress, '')
      
      loadNextChunk()
    }
    
    loadNextChunk()
  })
}

async function checkFile(uploadTask) {
  try {
    const res = await axios.get('http://localhost:8083/file/check', {
      params: { 
        md5: uploadTask.md5,
        fileSize: uploadTask.size
      }
    })
    
    const responseData = res.data
   
    
    const data = responseData.data
    const isUploaded = data.isUploaded
    const chunkList = data.chunkList || []
    
    if (isUploaded) {
      // 秒传成功处理
      uploadStore.completeUpload(uploadTask.id)
      ElMessage.success('文件秒传成功')
      return true
    } else {
      uploadTask.chunkList = chunkList
      uploadTask.needUpload = true
      return false
    }
  } catch (error) {
    console.error('检查文件失败:', error)
    ElMessage.error('文件检查失败: ' + error.message)
    uploadTask.needUpload = true
    uploadTask.chunkList = []
    return false
  }
}

async function normalUpload(uploadTask) {
  const formData = new FormData()
  formData.append('file', uploadTask.file)
  formData.append('folderId', uploadTask.folderId)
  formData.append('versionId', uploadTask.versionId)
  formData.append('encryptionType', uploadTask.encryptionType)
  
  try {
    const startTime = Date.now()
    
    await axios.post('http://localhost:8083/file/upload', formData, {
      headers: { 'Content-Type': 'multipart/form-data' },
      onUploadProgress: (progressEvent) => {
        if (progressEvent.lengthComputable) {
          const progress = Math.round((progressEvent.loaded / progressEvent.total) * 100)
          
          const duration = (Date.now() - startTime) / 1000
          let speed = '0 M/s'
          if (duration > 0.1) {
            const loadedMB = progressEvent.loaded / (1024 * 1024)
            const speedMB = loadedMB / duration
            speed = `${speedMB.toFixed(1)} MB/s`
          }
          
          // 更新上传进度
          uploadStore.updateProgress(uploadTask.id, progress, speed)
        }
      }
    })
    
    // 标记为已完成
    uploadStore.completeUpload(uploadTask.id)
    ElMessage.success('文件解析成功，稍等正在上传中')
    
    setTimeout(() => {
      emit('upload-success')
      internalVisible.value = false
    }, 1500)
  } catch (error) {
    console.error('普通上传失败:', error)
    ElMessage.error(`上传失败: ${error.response?.data || error.message}`)
    uploadStore.setError(uploadTask.id)
  }
}

function startChunkUpload(uploadTask) {
  if (uploadTask.uploadingStop) return
  
  const file = uploadTask.file
  const CHUNK_SIZE = 521* 1024
  const chunkTotal = Math.ceil(file.size / CHUNK_SIZE)
  
  // 设置总分片数
  uploadStore.setTotalChunks(uploadTask.id, chunkTotal)
  
  // 确定下一个需要上传的分片索引
  let nextIndex = 1
  if (uploadTask.chunkList && uploadTask.chunkList.length > 0) {
    // 从最后一个已上传分片的下一个开始
    nextIndex = Math.max(...uploadTask.chunkList) + 1
  }
  
  // 开始上传分片
  uploadChunk(uploadTask, nextIndex, chunkTotal, CHUNK_SIZE)
}

async function uploadChunk(uploadTask, index, chunkTotal, chunkSize) {
  // 检查是否暂停
  if (uploadTask.uploadingStop) return
  
  const file = uploadTask.file
  if (index > chunkTotal) {
    // 所有分片已上传，但后端可能还未合并
    uploadStore.completeUpload(uploadTask.id)
    ElMessage.success('文件上传成功')
    setTimeout(() => {
      emit('upload-success')
      internalVisible.value = false
    }, 1500)
    return
  }
  
  // 跳过已上传的分片
  if (uploadTask.chunkList && uploadTask.chunkList.includes(index)) {
    uploadChunk(uploadTask, index + 1, chunkTotal, chunkSize)
    return
  }
  
  // 准备分片数据
  const start = (index - 1) * chunkSize
  const end = Math.min(index * chunkSize, file.size)
  const chunk = file.slice(start, end)
  
  const formData = new FormData()
  formData.append('chunk', chunk)
  formData.append('md5', uploadTask.md5)
  formData.append('index', index)
  formData.append('chunkTotal', chunkTotal)
  formData.append('fileSize', file.size)
  formData.append('fileName', file.name)
  formData.append('chunkSize', chunkSize)
  formData.append('folderId', uploadTask.folderId)
  formData.append('versionId', uploadTask.versionId)
  formData.append('encryptionType', uploadTask.encryptionType)
  
  try {
    const startTime = Date.now()
    
    await axios.post('http://localhost:8083/file/upload/chunk', formData, {
      headers: { 'Content-Type': 'multipart/form-data' }
    })
    
    const duration = (Date.now() - startTime) / 1000
    const speedMB = (chunkSize / (1024 * 1024)) / duration
    const speed = `${speedMB.toFixed(1)} MB/s`
    
    // 更新已上传分片列表
    uploadStore.addChunk(uploadTask.id, index)
    
    // 更新上传速度
    uploadStore.updateProgress(uploadTask.id, uploadTask.uploadPercentage, speed)
    
    // 如果是最后一个分片
    if (index === chunkTotal) {
      // 后端会自动合并，这里只需标记完成
      uploadStore.completeUpload(uploadTask.id)
      ElMessage.success('文件上传成功')
      setTimeout(() => {
        emit('upload-success')
        internalVisible.value = false
      }, 1500)
    } else {
      // 继续上传下一个分片
      uploadChunk(uploadTask, index + 1, chunkTotal, chunkSize)
    }
  } catch (error) {
    console.error(`分片 ${index} 上传失败:`, error)
    ElMessage.error(`分片 ${index} 上传失败: ${error.response?.data || error.message}`)
    uploadStore.setError(uploadTask.id)
  }
}

function handleUploadError(error) {
  console.error('上传错误:', error)
  ElMessage.error(`上传失败: ${error.response?.data || error.message}`)
}

function handlePauseRequest(fileId) {
  const file = uploadFiles.value.find(f => f.id === fileId)
  if (file) {
    uploadStore.pauseUpload(fileId)
  }
}

function handleResumeRequest(fileId) {
  const file = uploadFiles.value.find(f => f.id === fileId)
  if (file) {
    uploadStore.resumeUpload(fileId)
    // 如果是分片上传，继续上传
    if (file.isChunked) {
      startChunkUpload(file)
    }
  }
}

// 暂停上传
function pauseUpload(id) {
  uploadStore.pauseUpload(id)
}

// 继续上传
function resumeUpload(id) {
  const upload = uploadStore.getUpload(id)
  if (upload) {
    uploadStore.resumeUpload(id)
    // 如果是分片上传，继续上传
    if (upload.isChunked) {
      startChunkUpload(upload)
    }
  }
}

// 移除上传任务
function removeUpload(id) {
  uploadStore.removeUpload(id)
}
</script>

<style scoped>
.upload-container {
  padding: 20px;
  background: linear-gradient(135deg, #f5f7fa 0%, #e4edf5 100%);
  border-radius: 10px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
}

.version-selector {
  width: 100%;
  margin-bottom: 20px;
}

.encryption-section {
  margin: 25px 0;
  padding: 20px;
  background-color: #ffffff;
  border-radius: 10px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
  border: 1px solid #ebeef5;
}

.encryption-section h3 {
  display: flex;
  align-items: center;
  font-size: 18px;
  color: #303133;
  margin-bottom: 15px;
  padding-bottom: 10px;
  border-bottom: 1px solid #ebeef5;
}

.info-icon {
  margin-left: 8px;
  color: #909399;
  cursor: pointer;
  transition: all 0.3s;
}

.info-icon:hover {
  color: #409eff;
  transform: scale(1.1);
}

.encryption-mode-select {
  margin-bottom: 20px;
}

.mode-description {
  margin-top: 12px;
  padding: 10px;
  background-color: #f0f9ff;
  border-radius: 6px;
  font-size: 14px;
  color: #606266;
}

.mode-description p {
  margin: 0;
}

.encryption-cards {
  display: flex;
  gap: 20px;
  margin-bottom: 20px;
}

.encryption-card {
  flex: 1;
  padding: 20px;
  border-radius: 10px;
  background-color: #f8fafc;
  border: 2px solid #e4e7ed;
  cursor: pointer;
  transition: all 0.3s ease;
  position: relative;
  overflow: hidden;
}

.encryption-card:hover {
  transform: translateY(-5px);
  box-shadow: 0 6px 15px rgba(0, 0, 0, 0.1);
}

.encryption-card.selected {
  border-color: #409eff;
  background-color: #ecf5ff;
  box-shadow: 0 0 0 2px rgba(64, 158, 255, 0.2);
}

.encryption-card.selected .card-icon {
  background: linear-gradient(135deg, #409eff, #64b5ff);
  color: white;
}

.encryption-card.selected.enhanced .card-icon {
  background: linear-gradient(135deg, #e6a23c, #eebe77);
}

.card-icon {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background-color: #e4e7ed;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 15px;
  font-size: 24px;
  color: #606266;
  transition: all 0.3s;
}

.card-icon.enhanced {
  background-color: #fdf6ec;
  color: #e6a23c;
}

.card-content h4 {
  font-size: 18px;
  text-align: center;
  margin-bottom: 12px;
  color: #303133;
}

.card-content p {
  color: #606266;
  font-size: 14px;
  line-height: 1.5;
  margin-bottom: 10px;
}

.card-content ul {
  padding-left: 20px;
  margin: 12px 0;
}

.card-content li {
  font-size: 13px;
  color: #606266;
  margin-bottom: 6px;
  line-height: 1.4;
}

.card-footer {
  text-align: center;
  margin-top: 15px;
}

.encryption-warning {
  margin-top: 20px;
}

.upload-box {
  margin: 20px 0;
  text-align: center;
}

.selected-file {
  margin-top: 10px;
  font-size: 14px;
  color: #666;
  min-height: 24px;
  padding: 8px 12px;
  background-color: #f8fafc;
  border-radius: 6px;
  border: 1px dashed #dcdfe6;
}

.confirm-btn {
  width: 100%;
  margin-top: 15px;
  margin-bottom: 20px;
  height: 42px;
  font-size: 16px;
  background: linear-gradient(90deg, #409eff, #64b5ff);
  border: none;
  transition: all 0.3s ease;
}

.confirm-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(64, 158, 255, 0.4);
}

.confirm-btn:disabled {
  background: #c0c4cc;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.progress-list {
  max-height: 400px;
  overflow-y: auto;
  padding: 15px;
  border: 1px solid #ebeef5;
  border-radius: 8px;
  background-color: #ffffff;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.upload-item {
  padding: 12px;
  border-bottom: 1px solid #ebeef5;
  transition: all 0.3s;
}

.upload-item:hover {
  background-color: #f8fafc;
}

.upload-item:last-child {
  border-bottom: none;
}

.file-info {
  display: flex;
  justify-content: space-between;
  margin-bottom: 8px;
}

.file-name {
  font-weight: 500;
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  padding-right: 10px;
}

.file-size {
  color: #909399;
  font-size: 13px;
  min-width: 70px;
  text-align: right;
}

.progress-info {
  margin-bottom: 8px;
}

.progress-details {
  display: flex;
  justify-content: space-between;
  margin-top: 5px;
  font-size: 12px;
}

.speed {
  color: #409eff;
}

.status {
  color: #909399;
}

.actions {
  display: flex;
  justify-content: flex-end;
  gap: 5px;
}

h2 {
  font-size: 18px;
  color: #303133;
  margin-bottom: 20px;
  text-align: center;
  font-weight: 600;
  position: relative;
  padding-bottom: 10px;
}

h2::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 60px;
  height: 3px;
  background: linear-gradient(90deg, #409eff, #64b5ff);
  border-radius: 3px;
}

.progress-list::-webkit-scrollbar {
  width: 8px;
}

.progress-list::-webkit-scrollbar-track {
  background: #f1f1f1;
  border-radius: 4px;
}

.progress-list::-webkit-scrollbar-thumb {
  background: #c1c1c1;
  border-radius: 4px;
}

.progress-list::-webkit-scrollbar-thumb:hover {
  background: #a8a8a8;
}

/* 加密信息对话框样式 */
.encryption-info {
  padding: 10px;
}

.encryption-info h3 {
  display: flex;
  align-items: center;
  font-size: 20px;
  margin-bottom: 20px;
  color: #303133;
}

.encryption-info h3 .el-icon {
  margin-right: 10px;
  color: #409eff;
}

.info-section {
  margin-bottom: 25px;
}

.info-section h4 {
  font-size: 18px;
  color: #409eff;
  margin-bottom: 10px;
  padding-bottom: 8px;
  border-bottom: 1px dashed #ebeef5;
}

.info-section p {
  margin-bottom: 10px;
  line-height: 1.6;
  color: #606266;
}

.info-section ul {
  margin: 15px 0 15px 20px;
}

.info-section li {
  margin-bottom: 8px;
  line-height: 1.5;
  color: #606266;
}

.warning {
  color: #e6a23c;
  font-weight: 500;
  padding: 10px;
  background-color: #fdf6ec;
  border-radius: 4px;
  margin-top: 15px;
}

.highlight {
  color: #409eff;
  font-weight: 600;
}
</style>